// 详情
import formJs from "./regexDetail.js"; //新增弹框配置项
import TableData from "@/components/public/el-table"; //主页面列表
//主页面列表
import publicForm from "@/components/public/el-form.vue"; //弹框form
import {
    getSampleConserveByFid, //详情
} from "@/api/request.js";
export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "statusNum",
        "currentRow",
        "pageStatus",
    ],
    data() {
        return {
            visible: "",
            title: null,
            loading: false,
            tableData: [],
            searchObj: formJs.searchObj, //搜索条件
            table_config: null, //列表
            queryCriteriaData: {}, //分页
            dialogHeight: null,
            formObj: formJs.formObj,
            isEdit: false,
            currntData: null,
            dataInfo: null,
            formData: {},
            currentDetail: null,
            types:null
        };
    },
    components: {
        publicForm,
        TableData
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },
        statusNum: {
            handler(newVal) {
                if (newVal) {
                    this.edit(newVal);
                }
            },
            immediate: true,
        },
        pageStatus: {
            handler(newVal) {
                if (newVal) {
                    if (newVal == 1) { //入库
                        this.table_config = formJs.table_config1
                    } else if (newVal == 2) {
                        this.table_config = formJs.table_config2
                    }
                }
            },
            immediate: true,
        },
        currentRow: {
            handler(newVal) {
                if (newVal) {
                    this.currentDetail = newVal;
                    this.getDetail({
                        fId:newVal.fId
                    })

                }
            },
            immediate: true,
        },
    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("monitorBack-userInfo"));
        this.btnShow = true
        if (this.statusNum == 7) { //查看
            this.btnShow = false
            this.formObj.map((item) => {
                item.disabled = true;
            });
        }
        this.getHeight();
    },
    methods: {
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.76 + "px";
        },
        closeDialog() {
            this.$emit("close");
        },
        edit() {
            this.formData = this.$options.data.call(this).formData;
        },
        // 详情
        getDetail(obj) {
            this.loading=true;
            getSampleConserveByFid(obj).then((res) => {
                if (res.errcode == 0) {
                    this.loading=false;
                    var data = res.data.yjQmpYpCheckSampleconserve;
                    this.formData = data;
                    this.tableData = data.itemsList
                }else {
                    this.loading=false;
                    this.$message.error(res.msg);
                }
            });
        },
    },
};